package groups.diseases.dao;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import groups.common.DBDumper;
import groups.common.dao.JDBCGenericDAO;
import groups.common.dao.SQLTable;
import groups.diseases.Disease;
import groups.diseases.DiseaseCausesSymptom;

public class JDBCDiseaseDAO extends JDBCGenericDAO<Disease>  {
	
	public JDBCDiseaseDAO(Connection connection) throws SecurityException, NoSuchMethodException{
		table = new SQLTable(Disease.class, "Disease", connection);
		table.addColumnMethod("idDisease", 	"getId",		true,	true);
		table.addColumnMethod("name", 		"getName",		false, false);
		table.addColumnMethod("endemic",	"isEndemic" ,	false, false);
	}
	
	public static void main(String[] args) {
		try {
			DBDumper dumper = new DBDumper("org.apache.derby.jdbc.EmbeddedDriver", "jdbc:derby:endemics;create=true", "", "");
			Disease d = new Disease(0, "testadae", false);
			new JDBCDiseaseDAO(dumper.initDB()).create(d);
			System.out.println(d.getId() + " " +d.getName()+ " " + d.isEndemic());
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}